import { QuoteHeader } from "quote";

/**
 * 通用的对象列表排序方法
 * 
 * @export
 * @param {string} key 排序的索引属性
 * @param {boolean} isIncr 升降序参数
 * @returns {(pre: any, next:any) => number} 
 */
export function sortFn(key: string, isIncr: boolean): (pre: any, next: any) => number {
  return (pre, next) => {
    let k = key || "symbol",
      asc = !isIncr,
      flag;
    if (pre[k] < next[k]) flag = -1;
    else if (pre[k] == next[k]) flag = 0;
    else flag = 1;
    return asc ? flag : -flag;
  };
};


export function getFixedSizeArray(arr, size): any[] {
  let lastIndex = arr.length;
  arr.length = size;
  return arr.fill({
    // symbol: (Date.now() + Math.floor(Math.random() * 10000)).toString()
  }, lastIndex);
}

export const getHeightOfElem = (elem: HTMLElement) => elem.getBoundingClientRect();
